<template>
  <div @click="btn" class="btn"
  :class="{
      primary: type === 'primary',
      deanger: type === 'deanger'
  }"
  >
      <slot >按钮</slot>

  </div>
</template>

<script>
export default {
    props: {
        type:String
    },
    methods: {
        btn(e) {
            // 子组件监听单击事件，通过$emit发出事件
            this.$emit('click',e)
        }
    }
}
</script>

<style lang="less" scoped>
    .btn{
    width: 318px;
    height: 48px;
    border-radius: 24px;
    background-color: #ccc;
    color: #666;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20xp;
    margin: 20px auto;
    }
    .primary{
        background-color: #07c160;
        color: #fff;
    }
    .deanger{
        background-color: #ee0a24;
        color: #fff;
    }
</style>